#include "stdafx.h"
#include "ClientPacketHandler.h"

#include <Network/TcpPacket.h>
#include <Game/Message.h>

ClientPacketHandler::ClientPacketHandler(void)
{
}


ClientPacketHandler::~ClientPacketHandler(void)
{
}

void ClientPacketHandler::OnConnected(TcpConnection*, int error)
{
	if( 0 == error )
		OnStarted();
}

void ClientPacketHandler::OnClosed(TcpConnection*, int)
{
	OnStopped();
}

void ClientPacketHandler::OnSent(TcpConnection*, int)
{
	// do nothing
}

void ClientPacketHandler::OnReceived(TcpConnection*, TcpPacket* packet, int error)
{
	if( MSG_LOGIN == packet->messageId_ )
	{
		msg_login_rs* rs = (msg_login_rs*)packet->payload_;
		OnLogin(rs->result);
	}
	else if( packet->messageId_ )
	{
	}
}
